define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'user.unset_apply/index',
        add_url: 'user.unset_apply/add',
        edit_url: 'user.unset_apply/edit',
        delete_url: 'user.unset_apply/delete',
        export_url: 'user.unset_apply/export',
        modify_url: 'user.unset_apply/modify',
        agree_url: 'user.unset_apply/agree',
        refuse_url: 'user.unset_apply/refuse',
        restore_url: 'user.unset_apply/restore',
    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                cols: [[
                    {field: 'id', title: 'id', search:false,},
                    {field: 'mobile', title: '手机号', sort:false, width:150,},
                    {field: 'unset_type', title: '注销类型', sort:false,},
                    {field: 'reason', title: '注销原因', sort:false,},
                    {field: 'old_user_nickname', title: '注销前昵称', sort:false,},
                    {field: 'old_avatar', title: '注销前头像', sort:false, templet: ea.table.image},
                    {field: 'status', search: 'select', selectList: ea.getDataBrage('select_list_status'), title: '审核状态'},
                    {field: 'unset_time', title: '注销时间', minWidth:150},
                    {field: 'create_time', title: '创建时间', minWidth:150},
                    {
                        minWidth: 150,
                        title: '操作',
                        fixed:'right',
                        templet: ea.table.tool,
                        operat: [
                            [{
                                text: '删除',
                                extra:'name',
                                url: init.delete_url,
                                method: 'request',
                                auth: 'delete',
                                class: 'layui-btn layui-btn-xs layui-btn-danger',
                                extend: 'data-full="false" data-end-method="refresh-page"',
                                _if: function (data, operat) {
                                    if (data.status == 0) {
                                        return true;
                                    }
                                    return false;
                                }
                            },{
                                title: '同意后，用户将注销，请确认后操作',
                                text: '同意申请',
                                extra:'name',
                                url: init.agree_url,
                                method: 'request',
                                auth: 'agree',
                                class: 'layui-btn layui-btn-xs layui-btn-blue',
                                extend: 'data-full="false" data-end-method="refresh-page"',
                                _if: function (data, operat) {
                                    if (data.status == 0) {
                                        return true;
                                    }
                                    return false;
                                }
                            },{
                                text: '拒绝申请',
                                extra:'name',
                                url: init.refuse_url,
                                method: 'request',
                                auth: 'refuse',
                                class: 'layui-btn layui-btn-xs layui-btn-danger',
                                extend: 'data-full="false" data-end-method="refresh-page"',
                                _if: function (data, operat) {
                                    if (data.status == 0) {
                                        return true;
                                    }
                                    return false;
                                }
                            },{
                                text: '恢复使用',
                                extra:'name',
                                url: init.restore_url,
                                method: 'request',
                                auth: 'refuse',
                                class: 'layui-btn layui-btn-xs layui-btn-success',
                                extend: 'data-full="false" data-end-method="refresh-page"',
                                _if: function (data, operat) {
                                    if (data.status == 1) {
                                        return true;
                                    }
                                    return false;
                                }
                            }],
                        ],
                    },
                ]],
                toolbar:['refresh'],
            });

            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
    };
    return Controller;
});